#ifndef _UTIL_H_DACHI_
#define _UTIL_H_DACHI_

#include <vector>
#include <string>

#include <sstream>
#include <iostream>
#include <utility>

#include "Progress.h"

class Game;

class Location;
class Indoors;
class Outdoors;

class Character;
struct dialog;
//class Progress;
//struct Progress::ach;
class Wizard;
class Barbarian;
class Paladin;

class Item;
class OtherItem;
class Weapon;
class Armor;
//#include "Locations/Location.h"
//#include "Locations/Indoors.h"
//#include "Locations/Outdoors.h"

//#include "Characters/Character.h"
//#include "Characters/Wizard.h"
//#include "Characters/Barbarian.h"
//#include "Characters/Paladin.h"

//#include "Items/Item.h"
//#include "Items/OtherItem.h"
//#include "Items/Weapon.h"
//#include "Items/Armor.h"

struct cmdalt
{
	std::string first;
	std::vector<std::string> second;
	
	bool exists(std::string in)
	{
		for(size_t i=0; i<second.size() ; i++)
		{
			if(second[i].compare(in) == 0)
			{
				return true;
			}
		}
		return false;
	}
};

std::vector<std::string> read(std::vector<cmdalt> alternatives, std::string message);
void printAlternatives(std::vector<cmdalt> alt);
void speak(std::string output, Character* speaker = NULL);
void speak(std::vector<std::string> input, Character * speaker = NULL);
void speak(std::string say, bool male, int pitch);

std::vector<std::string> get_save_files();

bool save(Game &, std::string);
bool saveGameExists(std::string);

bool saveGame(Game &, std::ofstream&);

bool saveLocation(Location &, std::ofstream &, Character* player = NULL);
bool saveLocationExtras(Location &, std::ofstream &);
bool saveLocationExtras(Indoors &, std::ofstream &);
bool saveLocationExtras(Outdoors &, std::ofstream &);

bool saveCharacter(Character & , std::ofstream &);
bool saveCharacterExtras(Character &, std::ofstream &);
bool saveCharacterExtras(Wizard & , std::ofstream &);
bool saveCharacterExtras(Paladin & , std::ofstream &);
bool saveCharacterExtras(Barbarian & , std::ofstream &);
bool saveDialog(dialog &, std::ofstream &);
bool saveAchievement(Progress::ach& a, std::ofstream & savestream);
bool saveProgress(Progress & prog, std::ofstream & savestream);

bool saveItem(Item &, std::ofstream &);
bool saveItemExtras(Item &, std::ofstream &);
bool saveItemExtras(OtherItem & , std::ofstream &);
bool saveItemExtras(Weapon & , std::ofstream &);
bool saveItemExtras(Armor &, std::ofstream &);

bool load(Game &g, std::string savename);
bool loadGame(Game &g, std::ifstream & input);

Location* loadLocation(Game &g, std::ifstream & input);
Character* loadCharacter(std::ifstream &);
Progress* loadProgress(std::ifstream& input);
bool loadDialog(std::vector<dialog>&, std::ifstream &);
bool loadAchievement(Progress::ach& a, std::ifstream & savestream);
Item* loadItem(std::ifstream & input);

std::vector<std::string> split(const std::string &s, char delim);

#endif
